home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UUPC11QS.ARJ / LIB.H < prev    next >
C/C++ Source or Header  |  1991-11-17  |  13KB  |  297 lines

  1. /*--------------------------------------------------------------------*/
  2. /*      l i b . h                                                     */
  3. /*                                                                    */
  4. /*      Update log:                                                   */
  5. /*                                                                    */
  6. /*      13 May 89    Added PCMAILVER                        ahd       */
  7. /*      Summer 89    Added equali, equalni, compiled,                 */
  8. /*                         compilet                         ahd       */
  9. /*      22 Sep 89    Add boolean typedef                    ahd       */
  10. /*      01 Oct 89    Make logecho boolean                   ahd       */
  11. /*      19 Mar 90    Move FOPEN prototype to here           ahd       */
  12. /*      02 May 1990  Allow set of booleans options via options=       */
  13. /*  8 May  90  Add 'pager' option                                     */
  14. /* 10 May  90  Add 'purge' option                                     */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. #ifndef __LIB
  18. #define __LIB
  19.  
  20. /*--------------------------------------------------------------------*/
  21. /*     Environment variables set by UUXQT before invoking modules     */
  22. /*--------------------------------------------------------------------*/
  23.  
  24. #define UU_USER "UU_USER"
  25. #define UU_MACHINE "UU_MACHINE"
  26. #define LOGNAME "LOGNAME"
  27.  
  28. /*--------------------------------------------------------------------*/
  29. /*                 Macro for recording when UUPC dies                 */
  30. /*--------------------------------------------------------------------*/
  31.  
  32. #define panic()  bugout( __LINE__, cfnptr)
  33.  
  34. /*--------------------------------------------------------------------*/
  35. /*                 Macro for generic error messages from DOS          */
  36. /*--------------------------------------------------------------------*/
  37.  
  38. #define printerr( x )  prterror( __LINE__, cfnptr, x)
  39.  
  40. /*--------------------------------------------------------------------*/
  41. /*                     Configuration file defines                     */
  42. /*--------------------------------------------------------------------*/
  43.  
  44. #define B_REQUIRED 0x00000001     /* Line must appear in configuration   */
  45. #define B_FOUND    0x00000002     /* We found the token                  */
  46.  
  47. #define B_GLOBAL   0x00000004 /* Must not appear in PERSONAL.RC      */
  48. #define B_LOCAL    0x00000008 /* The opposite of B_GLOBAL, sort of   */
  49.  
  50. #define B_MUA      0x00000010 /* Used by Mail User Agent (MAIL)      */
  51. #define B_UUIO     0x00000020 /* Used by transport program (UUIO)    */
  52. #define B_MTA      0x00000040 /* Used by Mail Delivery (RMAIL)       */
  53. #define B_UUCP     0x00000080 /* Used by UUCP command                */
  54. #define B_NEWS     0x00000100 /* Used by NEWS software               */
  55. #define B_MUSH     0x00000200 /* Used by MUSH - Not used by UUPC     */
  56. #define B_MAIL     (B_MUA | B_MTA | B_MUSH)
  57. #define B_ALL      (B_MUA | B_MTA | B_MUSH | B_UUIO | B_NEWS | B_UUCP)
  58. #define B_SPOOL    (B_MTA | B_UUIO| B_UUCP)
  59.  
  60. #define B_INTEGER  0x00000400 /* Pointer is to short int, not string */
  61. #define B_TOKEN    0x00000800 /* Pointer is one word, ignore blanks  */
  62. #define B_BOOLEAN  0x00001000 /* Pointer is to boolean keywords      */
  63. #define B_LIST     0x00002000 /* Pointer to array of char pointers   */
  64. #define B_CLIST    0x00004000 /* Pointet to array of char pointers,
  65.                                  input is separated by colons, not
  66.                                  spaces                              */
  67. #define B_STRING   0x00008000 /* String value (same as original UUPC)*/
  68.  
  69. /*--------------------------------------------------------------------*/
  70. /*                     General defines and macros                     */
  71. /*--------------------------------------------------------------------*/
  72.  
  73. #define  MESSAGESEP "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n"
  74.  
  75. #define DCSTATUS    "hostatus"
  76. #define LOGFILE     "uucico.log"
  77. #define XQTLOG      "uuxqt.log"
  78. #define PASSWD      "passwd"
  79. #define PATHS       "hostpath"
  80. #define PERMISSIONS "permissn"
  81. #define RMAILLOG    "rmail.log"
  82. #define SYSLOG      "syslog"
  83. #define SYSTEMS     "systems"
  84.  
  85. #define WHITESPACE " \t\n\r"
  86.  
  87. /*--------------------------------------------------------------------*/
  88. /*    Equality macros                                                 */
  89. /*--------------------------------------------------------------------*/
  90.  
  91. #define equal(a,b)               (!strcmp(a,b))
  92. #define equali(a,b)              (!stricmp(a,b))                     /*ahd */
  93. #define equalni(a,b,n)           (!strnicmp(a,b,n))                  /*ahd */
  94. #define equaln(a,b,n)            (!strncmp(a,b,n))
  95.  
  96. #define currentfile()            static char *cfnptr = __FILE__
  97. #define checkref(a)              (checkptr(a, cfnptr ,__LINE__));    /*ahd */
  98.  
  99. #define nil(type)               ((type *)NULL)
  100.  
  101. /*--------------------------------------------------------------------*/
  102. /*    Enumerated list used by the options= configuration line         */
  103. /*--------------------------------------------------------------------*/
  104.  
  105. typedef enum {
  106.                /* Per user options */
  107.                F_ASKCC,       /* TRUE = ask for Carbon copies              */
  108.                F_DOSKEY,      /* TRUE = Use DOSKEY under DOS 5 if available*/
  109.                F_BACKUP,      /* TRUE = Backup mailbox before rewriting    */
  110.                F_DOT,         /* TRUE = period ends a message              */
  111.                F_AUTOPRINT,   /* TRUE = print next message automatically   */
  112.                F_AUTOEDIT,    /* TRUE = no line prompt, always edit        */
  113.                F_AUTOINCLUDE, /* TRUE = Perform automatic INCLUDE command  */
  114.                F_AUTOSIGN,    /* TRUE = append the signature file          */
  115.                F_EXPERT,      /* TRUE = Let user shoot self in foot w/o
  116.                                         a message.                         */
  117.                F_FROMSEP,     /* TRUE = Allow From to split messages       */
  118.                F_PAGER,       /* TRUE = Invert meaning of P/p T/t commands */
  119.                F_PURGE,       /* TRUE = Delete mailbox, if empty           */
  120.                F_SAVE,        /* TRUE = Save read messages in =mbox when
  121.                                         reading new mail.                  */
  122.                F_DIRECT,      /* TRUE = Deliver to subdirectories, not
  123.                                         files                              */
  124.                F_SAVERESENT,  /* TRUE = Save forwarded mail a second time  */
  125.                F_VERBOSE,     /* TRUE = Verbose RMAIL output               */
  126.  
  127.                /* Per system (GLOBAL) options */
  128.                F_BANG,        /* TRUE = re-write addresses in bang (!) form*/
  129.                F_HISTORY,     /* TRUE = Maintain history of of articles
  130.                                         read and posted                    */
  131.                F_KANJI,       /* TRUE = enable Kanji (Japanese) support    */
  132.                F_MULTI,       /* TRUE = Deliver to multiple addresses on
  133.                                         remote host at once                */
  134.                F_ONECASE,     /* TRUE = Remote host is case insensitive    */
  135.                F_SYSLOG,      /* TRUE = Write syslog with name and time of
  136.                                         each file transferred              */
  137.                F_LAST }       /* Dummy - Must be last - defines array size */
  138.                B_FLAG;        /* Boolean flag array - ahd                  */
  139.  
  140. /*--------------------------------------------------------------------*/
  141. /*                  Your basic Boolean logic values                   */
  142. /*--------------------------------------------------------------------*/
  143.  
  144. #undef FALSE
  145. #undef TRUE
  146. typedef enum { FALSE = 0, TRUE = 1 } boolean;
  147.  
  148. /*--------------------------------------------------------------------*/
  149. /*                      Configuration mode flags                      */
  150. /*--------------------------------------------------------------------*/
  151.  
  152. typedef enum {
  153.       USER_CONFIG,
  154.       SYSTEM_CONFIG,
  155.       MODEM_CONFIG
  156.       } SYSMODE;
  157.  
  158. /*--------------------------------------------------------------------*/
  159. /*               enumerated type for configuration bits               */
  160. /*--------------------------------------------------------------------*/
  161.  
  162. typedef unsigned long CONFIGBITS;
  163.  
  164. typedef unsigned short INTEGER;  /* Integers in the config file      */
  165.  
  166. typedef unsigned int BPS;
  167.  
  168. /*--------------------------------------------------------------------*/
  169. /*                     Configuration table layout                     */
  170. /*--------------------------------------------------------------------*/
  171.  
  172. typedef struct ConfigTable {
  173.    char *sym;
  174.    char **loc;
  175.    CONFIGBITS bits;
  176. } CONFIGTABLE;
  177.  
  178. /*--------------------------------------------------------------------*/
  179. /*                    Boolean options table layout                    */
  180. /*--------------------------------------------------------------------*/
  181.  
  182. typedef struct FlagTable {
  183.    char *sym;
  184.    int position;
  185.    CONFIGBITS bits;
  186. } FLAGTABLE;
  187.  
  188. /*--------------------------------------------------------------------*/
  189. /*                            linked list                             */
  190. /*--------------------------------------------------------------------*/
  191.  
  192. struct file_queue {
  193.    char name[FILENAME_MAX];
  194.    struct file_queue *next_link;
  195. } ;
  196.  
  197. /*--------------------------------------------------------------------*/
  198. /*                          Global variables                          */
  199. /*--------------------------------------------------------------------*/
  200.  
  201. extern int debuglevel;
  202. extern boolean logecho;
  203. extern FILE *logfile;
  204. extern boolean bflag[F_LAST];
  205.  
  206. /*--------------------------------------------------------------------*/
  207. /*      Configuration file strings                                    */
  208. /*--------------------------------------------------------------------*/
  209.  
  210. extern char *name, *mailbox, *homedir;
  211. extern char *archivedir, *newsserv;                            /* news */
  212. extern char *mailbox, *homedir;
  213. extern char *maildir, *newsdir, *spooldir, *confdir, *pubdir, *tempdir;
  214. extern char *nodename, *domain, *mailserv;
  215. extern char *fdomain;         /* Domain used in From: lines             */
  216. extern char *E_inmodem;
  217. extern char *E_editor, *E_pager;
  218. extern char *E_mailext, *E_backup;
  219. extern char *E_filesent, *E_signature;
  220. extern char *E_altsignature;                                   /* pdm   */
  221. extern char *aliases;                                          /* ahd   */
  222. extern char *organization, *replyto;                           /* ahd   */
  223. extern char *localdomain;                                      /* ahd   */
  224. extern char *postmaster;                                       /* ahd   */
  225. extern char *E_rmail;
  226. extern char *E_rnews;
  227. extern char *E_uuxqtpath;
  228. extern char *E_charset;
  229. extern char *anonymous;
  230. extern INTEGER maxhops;
  231. extern INTEGER PacketTimeout;
  232. extern INTEGER PortTimeout;
  233. extern INTEGER MaxErr;
  234. extern INTEGER xfer_bufsize;
  235.  
  236. extern FLAGTABLE configFlags[];
  237.  
  238. /*--------------------------------------------------------------------*/
  239. /*                        Function prototypes                         */
  240. /*--------------------------------------------------------------------*/
  241.  
  242. void prterror(const size_t lineno, const char *fname, const char *prefix);
  243.  
  244. extern void checkptr(const void *block, const char *file, const int line);
  245.  
  246. extern int MKDIR(const char *path);
  247.                               /* Make a directory              ahd */
  248.  
  249. extern int CHDIR(const char *path);
  250.                               /* Change to a directory          ahd */
  251.  
  252. extern int CREAT(const char *name,
  253.                  const int mode,
  254.                  const char ftype);                          /* ahd */
  255.  
  256. int RENAME(const char *oldname, const char *newname );
  257. extern FILE *FOPEN(const char *name,
  258.                    const char *mode,
  259.                    const char ftype);                       /* ahd   */
  260.  
  261. extern void options(char *s,
  262.                     SYSMODE sysmode ,
  263.                     FLAGTABLE *flags,
  264.                     boolean *xflag);
  265.  
  266. int getargs(char *line,
  267.             char **flds);                                   /* ahd */
  268.  
  269. void printmsg(int level, char *fmt, ...);
  270.  
  271. boolean configure( CONFIGBITS program );
  272.  
  273. boolean getconfig(FILE *fp,
  274.                   SYSMODE sysmode,
  275.                   CONFIGBITS program,
  276.                   CONFIGTABLE *table,
  277.                   FLAGTABLE *btable);
  278.  
  279. boolean processconfig(char *buff,
  280.                   SYSMODE sysmode,
  281.                   CONFIGBITS program,
  282.                   CONFIGTABLE *table,
  283.                   FLAGTABLE *btable);
  284.  
  285. void bugout( const size_t lineno, const char *fname);
  286.  
  287. /*--------------------------------------------------------------------*/
  288. /*                   Compiler specific information                    */
  289. /*--------------------------------------------------------------------*/
  290.  
  291. #if defined(__CORE__)
  292. extern   char *copyright;
  293. extern   char *copywrong;
  294. extern   long *lowcore;
  295. #endif   /* defined(__CORE__)   */
  296. #endif   /* ifndef __LIB */
  297.